<!--
  模块：专项申报 - 详情
-->
<template>
  <div class="declare-detail">
    <AppMainContent>
      <el-card>
        <CardFormTitle title="申报信息" />
        <CardFormContent>
          <!-- 表单内容 -->
          <el-form :inline="true" label-position="top" label-width="auto">
            <el-row :gutter="20">
              <el-col :span="6">
                <el-form-item label="申报标题">
                  <el-input
                    class="formTitle"
                    :value="detailContent.title"
                    :disabled="true"
                  ></el-input>
                </el-form-item>
              </el-col>

              <el-col :span="4">
                <el-form-item label="申报开始时间">
                  <el-date-picker
                    type="datetime"
                    :value="detailContent.startTime"
                    :disabled="true"
                  ></el-date-picker>
                </el-form-item>
              </el-col>

              <el-col :span="4">
                <el-form-item label="申报截止时间">
                  <el-date-picker
                    type="datetime"
                    :value="detailContent.endTime"
                    :disabled="true"
                  ></el-date-picker>
                </el-form-item>
              </el-col>

              <el-col :span="4">
                <el-form-item label="发布人">
                  <el-input
                    :value="detailContent.publishUserName"
                    :disabled="true"
                    class="elInput"
                  ></el-input>
                </el-form-item>
              </el-col>

              <el-col :span="4">
                <el-form-item label="发布时间">
                  <el-input
                    :value="detailContent.publishTime"
                    :disabled="true"
                    class="elInput"
                  ></el-input>
                </el-form-item>
              </el-col>
            </el-row>

            <!-- 上传 -->
            <el-form :inline="true" label-position="top">
              <el-form-item label="上传文件">
                <el-upload
                  style="display: inline-flex"
                  class="upload-demo"
                  action=""
                  multiple
                  :limit="3"
                ></el-upload>
                <el-form-item>
                  <el-input
                    disabled
                    style="display: inline-flex; width: 300px"
                    :v-model="{ fileList }"
                  ></el-input>
                </el-form-item>
                <el-form-item>
                  <el-input
                    disabled
                    style="display: inline-flex; width: 300px"
                  ></el-input>
                </el-form-item>
              </el-form-item>
            </el-form>

            <el-form :inline="true" label-position="top">
              <el-form-item label="文本内容">
                <el-input
                  type="textarea"
                  :value="detailContent.content"
                  :disabled="true"
                  resize="none"
                  class="textareaContent"
                  :autosize="{minRows:15,maxRows:35}"
                />
              </el-form-item>
            </el-form>
          </el-form>
        </CardFormContent>
      </el-card>
    </AppMainContent>
    <!-- 版权 -->
    <Copyright />
  </div>
</template>

<script>
import { fetchDeclare } from '@/api/declare/index'
// 版权
import Copyright from '@/components/copyright'
export default {
  name: 'DeclareDetail',
  components: { Copyright },
  data() {
    return {
      // 上传文件
      fileList: [],
      detailContent: {},
    }
  },
  // * 获取详情数据
  mounted() {
    let id = this.$route.query.id
    fetchDeclare(id).then((response) => {
      if (response.data != null) {
        this.detailContent = response.data
      } else {
        alert('网络延迟，请稍后再试')
      }
    })
  },
  // 监听 url 的 id 变化
  watch: {
    $route(to, from) {
      let id = this.$route.query.id
      fetchDeclare(id).then((response) => {
        if (response.data != null) {
          this.detailContent = response.data
        }
      })
    },
  },
}
</script>

<style lang="scss" scoped>
.declare-detail {
  height: 100%;
  overflow: scroll;
}
// 标题
.formTitle {
  display: inline-flex;
  width: 340px;
}
// input框
.elInput {
  width: 220px;
}
// 文本域
.textareaContent {
  width: 820px;
  height: 300px;
}

</style>
